<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文章列表</title>
<script src="./resource/bootstrap/bootstrap/js/bootstrap.min.js"></script>
<link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="./resource/css/index.css" rel="stylesheet">
</head>
<body>
<div class="container">
	<nav class="navbar navbar-inverse">
		<div class="container-fluid">
			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav navbar-right">
					<?php if(isset($_SESSION['username'])){ ?>
					<li><a href=""><?php echo $_SESSION['username']?></a></li>
					<li><a href="?c=user&a=logout">退出</a></li>
					<?php }else{ ?>
					<li><a href="?c=user&a=login">登录</a></li>
					<li><a href="?c=user&a=register">注册</a></li>
					<?php }?>
				</ul>
			</div><!-- /.navbar-collapse -->
		</div><!-- /.container-fluid -->
	</nav>
</div>
<?php if($data) {?>
<div class="listBox">
	<ul>
		<?php foreach($data as $v){ ?>

		<li>
			<a class='link' href="?a=show&id=<?php echo $v['id']?>"><?php echo $v['title']?></a>
            <a href="?a=edit&id=<?php echo $v['id']; ?>">编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="javascript:;" onclick="del(<?php echo $v['id']?>)">删除</a>
		</li>
		<?php }?>
	</ul>
</div>	
<?php }else{ ?>

<div class="listBox">
	<ul>
		<li><a class='link' href="">不好意思哦，还没有内容，等着你来添加哦！</a></li>
	</ul>
</div>

<?php }?>
<div class="pagination pagination-centered" style="width: 100%">
	<div style="margin: 0 auto;width: 100px">
		<nav aria-label="Page navigation" >
			<ul class="pagination">
				<li ><a href="?a=add">添加文章</a></li>
			</ul>
		</nav>
	</div>
</div>
<script>
	function del(id){
	    if(confirm('确定删除吗?')){
	        location.href='?a=del&id='+id;
		}
	}

</script>

</body>
</html>